package com.tools.common.enums;

import lombok.Getter;

/**
 * 审批操作枚举
 */
@Getter
public enum ApprovalActionEnum {


    APPROVE("APPROVE", "批准"),
    REJECT("REJECT", "拒绝"),
    RETURN("RETURN", "退回"),
    TRANSFER("TRANSFER", "转交"),
    CANCEL("CANCEL", "撤销");

    private final String code;
    private final String description;

    ApprovalActionEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举
     */
    public static ApprovalActionEnum getByCode(String code) {
        for (ApprovalActionEnum action : values()) {
            if (action.getCode().equals(code)) {
                return action;
            }
        }
        return null;
    }

    /**
     * 检查是否为有效操作
     */
    public static boolean isValid(String code) {
        return getByCode(code) != null;
    }

}
